%% process_showmesh
function process_showmesh(mesh, fespace, varargin)
node =  mesh.node;
elem = mesh.elem;
edge = mesh.edge;
Ne = mesh.Ne;
Np = mesh.Np;
Ned = mesh.Ned;
figure("WindowStyle", "docked");
% mesh
h = patch("Faces", elem, "Vertices", node);
set(h, "facecolor", "w", "edgecolor", "k");
axis("tight", "equal");
hold on;
% node
if isempty(varargin) || varargin{1}(1) == 1
    shift = 0.001;
    node_idx = (1:Np)';
    plot(node(node_idx,1), node(node_idx,2), "k.", "MarkerSize", 10);
    text(node(node_idx,1)+shift, node(node_idx,2)+shift, int2str(node_idx), "FontSize", 10, "FontWeight", "bold", "Color", "k");
    if ismember(fespace.basis_type, ["P1b", "P2", "P3", "P4", "P5"])
        node = fespace.node;
        Nb = fespace.Nb;
        plot(node(Np+1:end,1), node(Np+1:end,2), "k.", "MarkerSize", 10);
        text(node(Np+1:end,1)+shift, node(Np+1:end,2)+shift, int2str((Np+1:Nb)'), "FontSize", 10, "FontWeight", "bold", "Color", "k");
    end
end
% elem
if isempty(varargin) || varargin{1}(2) == 1
    center = zeros(Ne,2);
    for i = 1:Ne
        V = node(elem(i,:),:);
        center(i,:) = mean(V);
    end
    text(center(:,1), center(:,2), int2str((1:Ne)'), "FontSize", 10, "FontWeight", "bold", "Color", "r", "HorizontalAlignment", "right");
end
% edge
if isempty(varargin) || varargin{1}(3) == 1
    midpoint = 0.5*(node(edge(:,1),:) + node(edge(:,2),:));
    text(midpoint(:,1), midpoint(:,2), int2str((1:Ned)'), "FontSize", 10, "FontWeight", "bold", "Color", "b", "HorizontalAlignment", "right");
end
hold off
end